package com.wonders.module.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wonders.framework.util.bean.BeanUtil;
import com.wonders.module.auth.dao.MenuDao;
import com.wonders.module.auth.dao.UserDao;
import com.wonders.module.auth.entity.bo.User;
import com.wonders.module.auth.entity.vo.MenuVo;
import com.wonders.module.auth.entity.vo.UserVo;
import com.wonders.module.system.service.SystemService;

/**
 * 系统操作业务层实现
 * 
 * @author WuBin
 * 
 */
@Service
public class SystemServiceImpl implements SystemService {

	@Autowired
	private UserDao userDao;
	
	@Autowired
	private MenuDao menuDao;

	public UserVo getUser(UserVo userVo) {
		User user = userDao.getUser(userVo);
		return BeanUtil.copyProperties(user, UserVo.class);
	}

	public List<MenuVo> getUserMenu(Long userId) {
		return BeanUtil.copyList(menuDao.getUserMenu(userId), MenuVo.class);
	}

	public void editPassword(UserVo userVo) {
		List<Long> keys = new ArrayList<Long>();
		keys.add(userVo.getId());
		userDao.editPassword(keys, userVo.getPassword());
	}

}
